import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Copyright 2009-2019 wacai.com.
 */

/**
 * @author yuyi@wacai.com
 * @since 2019-06-23
 *
 */
public class GCTest1 {
	
	static int c[];
	
	static int b[];
	
	static int d[];
	
	static int e[];
	
	static List <User> children = new ArrayList<User>();

	/**
	 * @param args
	 * @throws InterruptedException 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws InterruptedException, IOException {
		
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			TimeUnit.MILLISECONDS.sleep(500);
			int[] a = new int[204800];
			System.out.println("第" + i + "次，数组长度：" +a.length);
			if (i % 20 == 1) {
				System.out.println("暂停--" + i);
//				System.in.read();
			}
			Map<Integer, Group> no2group = new HashMap<Integer, Group>();
			if (i % 10 == 1) {
				c = a;
				for (int j = 0; j < 1000 * 100; j++) {
					int groupNo = j % 100;
					Group existGroup = no2group.get(groupNo);
					if (existGroup == null) {
						existGroup = new Group(groupNo, "test-group-" + groupNo);
						no2group.put(i, existGroup);
					}
					User child = new User(j, "test-user-" + j, existGroup);
					children.add(child);
				}
				System.out.println("创建一堆User对象--" + i);
			}
			if (i % 10 == 9) {
				children.clear();
				System.out.println("清理一堆User对象--" + i);
			}
			if (i % 1000 == 1) {
				b = a;
			}
			if (i % 1000 == 2) {
				d = a;
			}
			if (i % 1000 == 3) {
				e = a;
			}
			if (i % 1000 == 50) {
				b = null;
				c= null;
			}
		}

	}
	

}
